package cn.sixmillions.demo01;

import cn.sixmillions.demo01.entity.Clazz;
import cn.sixmillions.demo01.entity.Student;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * 1. 构造方法实例化bean
 */
public class Spring02Application {

    public static void main(String[] args) {
        ApplicationContext context = new ClassPathXmlApplicationContext("student-clazz-02.xml");
        // 构造 + 参数名
        Clazz oneClazz = context.getBean("oneClazz", Clazz.class);
        System.out.println(oneClazz.toString());
        //构造 + 索引
        Clazz twoClazz = context.getBean("twoClazz", Clazz.class);
        System.out.println(twoClazz.toString());
        //构造 + 参数名 + set方法
        Student s1 = context.getBean("s1", Student.class);
        s1.say();

        //静态工厂创建bean
        Clazz staticOneClazz = context.getBean("staticOneClazz", Clazz.class);
        System.out.println(staticOneClazz);
        //工厂实例创建bean
        Clazz twoClazzInstance = context.getBean("twoClazzInstance", Clazz.class);
        System.out.println(twoClazzInstance);
    }
}
